







[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]
Searches a sorted list for an item via binary search. The list must be sorted
by the natural ordering of the type (it's implementation of IComparable<T>).
Namespace: Wintellect.PowerCollections
Assembly:
PowerCollections (in PowerCollections.dll)
Syntax
C# |
---|
public static int BinarySearch<T>( IList<T> list, T item, out int index ) where T : IComparable<T> |
Visual Basic (Declaration) |
---|
Public Shared Function BinarySearch(Of T As IComparable(Of T)) ( _ list As IList(Of T), _ item As T, _ <OutAttribute> ByRef index As Integer _ ) As Integer |
Visual C++ |
---|
public: generic<typename T> where T : IComparable<T> static int BinarySearch ( IList<T>^ list, T item, [OutAttribute] int% index ) |
Parameters
- list
- IList<(Of <T>)>
The sorted list to search.
- item
- T
The item to search for.
- index
- Int32%
Returns the first index at which the item can be found. If the return value is zero, indicating that item was not present in the list, then this returns the index at which item could be inserted to maintain the sorted order of the list.
Return Value
The number of items equal to item that appear in the list.
Type Parameters
- T
See Also
Algorithms Class
Wintellect.PowerCollections Namespace